package com.jch.helloworld.configBeans.BeanScope;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestMain {

    public static void main(String[] args) {
        // 创建IOC容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("/beans/beans-scope.xml");
        // 获取使用默认作用域的bean
        System.out.println("使用默认作用域的bean：");
        Demo demo00 = (Demo) ctx.getBean("d0");
        Demo demo01 = (Demo) ctx.getBean("d0");
        System.out.println("demo00 == demo01 : " + (demo00 == demo01));
        System.out.println("使用singleton(单例)作用域的bean：");
        Demo demo10 = (Demo) ctx.getBean("d1");
        Demo demo11 = (Demo) ctx.getBean("d1");
        System.out.println("demo10 == demo11 : " + (demo10 == demo11));
        System.out.println("使用prototype作用域的bean：");
        Demo demo20 = (Demo) ctx.getBean("d2");
        Demo demo21 = (Demo) ctx.getBean("d2");
        System.out.println("demo20 == demo21 : " + (demo20 == demo21));
    }

}
